package com.tanhua.domain.mongo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serializable;
import java.util.List;

/**
 * 每个用户的测试结果
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Document(collection = "soul_result")
public class SoulResult implements Serializable {
    /*主键id*/
    private ObjectId id;
    /*问卷id*/
    private ObjectId paperId;
    /*用户id*/
    private Long userId;
    /*答题结果*/
    private List<Answer> answers;
    /*答题得分汇总*/
    private Integer score;
    /*答题提交时间*/
    private Long created;
    /*用户答题报告*/
    private ObjectId reportId;

    public SoulResult(Integer score) {
        this.score = score;
        //在构造中根据score 得出 report 报告
        if (score <= 21) {
            reportId = new ObjectId("6187dc799cd30e609fa3ebba");
        } else if (score <= 40) {
            reportId = new ObjectId("6187dccd9cd30e609fa3ec2b");
        } else if (score <= 55) {
            reportId = new ObjectId("6187dd159cd30e609fa3ec9a");
        } else {
            reportId = new ObjectId("6187dd3d9cd30e609fa3ecc7");
        }
    }
}
